<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      /* 方式一：flex */
      /* .container {
        width: 800px;
        height: 400px;
        background-color: yellowgreen;
        display: flex;
        justify-content: center;
        align-items: center;
      } 
      
      .img {
        width: 100px;
        height: 100px;
      }
      */

      /* 方式二：定位 */
      .container {
        width: 800px;
        height: 400px;
        background-color: yellowgreen;
        position: relative;
      }

      .img {
        position: absolute;
        top: 50%;
        left: 50%;
        /* transform: translate(-50%, -50%); */
        margin-left: -50px;
        margin-top: -50px;
        width: 100px;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <img src="./5.png" alt="" class="img" />
    </div>
  </body>
</html>
